#ifndef __HAL_TEMPER_H
#define __HAL_TEMPER_H

#include "main.h"
#define RT_TABLE_NUM 121

#define NTC_OPEN 4050  // NTC开路//@7 NTC??
#define NTC_SHORT 4051 // NTC短路 //@7 NCT??
#define TEMPER_FIFO_LEN (12)
// #ifdef TESTMODE
// #define OVERTEMPVALUE 100  //过温值
// #else
#define OVERTEMPVALUE 125  //过温值
// #endif // DEBUG


#define MIN(a, b) ((a)>(b)?(b):(a))
#define MAX(a, b) ((a)>(b)?(a):(b))


#define ADC_FIL_TIMES 10   //管道最大的值

typedef enum
{   
		NTC_HEAT,			//热罐NTC
		NTC_COOL,   	//冷罐NTC
		NTC_SODA,   	//苏达NTC
		NTC_HEAT_L,		//热罐下NTC
		NTC_IN_WATER,	//进水NTC
	  NTC_MAX_NUM,
}teNTCIndex;




 typedef struct
 {
 	uint16_t buf[TEMPER_FIFO_LEN];
 	uint16_t max;
 	uint16_t min;
 	uint8_t top;
 	uint8_t bottom;
 	uint8_t len;
 	uint32_t sum;
 	uint16_t average;
	

 } ts_TemperFifoCtrl;

// extern tsHalTempCtrl haltempctrl;

// extern void init_temper(void);
//uint16_t ad_convert_to_temper(uint16_t advalue);
uint16_t temper_fifoch_push(ts_TemperFifoCtrl *pfifo, uint16_t data);
void temper_fifoch_clear(ts_TemperFifoCtrl *pfifo);

extern float get_ntc_temper(teNTCIndex adcindex);
extern uint16_t get_ntc_temper_ex(teNTCIndex adcindex);
 
extern float OnReadNTCtemper(teNTCIndex NTCindex);//@7 缩小10倍的算法

extern void OnTemperTest(void);
uint32_t OnGetNTCError(teNTCIndex NTCindex); //获取NTC故障
uint16_t adc_read_ch_filter(teNTCIndex adcindex);





#endif
